//package com.ssm.zookeeper;
//
//import org.apache.zookeeper.*;
//
//import java.util.concurrent.CountDownLatch;
//
//public class ZkClientTest {
//    private static final String CONNECT_STR = "localhost:2181";
//    private final static String CLUSTER_CONNECT_STR = "192.168.xx.156:2181,192.168.xx.190:2181,192.168.xx.200:2181";
//    static ZooKeeper zooKeeper;
//
//    public static void main(String[] args) throws Exception {
//        final CountDownLatch countDownLatch = new CountDownLatch(1);
//        zooKeeper = new ZooKeeper(CONNECT_STR, 4000, new Watcher() {
//            @Override
//            public void process(WatchedEvent event) {
//                if (Event.KeeperState.SyncConnected == event.getState()
//                        && event.getType() == Event.EventType.None) {
//                    //如果收到了服务端的响应事件，连接成功
//                    countDownLatch.countDown();
//                    System.out.println("连接建立");
//                }
//            }
//        });
//        System.out.printf("连接中");
//        countDownLatch.await();
//        //CONNECTED
//        System.out.println(zooKeeper.getState());
//
//        //创建持久节点
//        zooKeeper.create("/user", "tangwei".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
//
//    }
//
//}